from django.db import models
from .userModel import *
from .preOrderModel import *


class Order(models.Model):
    payway = models.CharField(max_length=10, default='wx', null=True)
    cart_id = models.CharField(max_length=32)
    address_info = models.CharField(max_length=100)
    user = models.ForeignKey(to=User, on_delete=models.SET_NULL, null=True)
    pre_order = models.ForeignKey(
        to=PreOrder, on_delete=models.SET_NULL, null=True)
    discount = models.CharField(max_length=32)
    all_fee = models.CharField(max_length=32)
    total_money = models.CharField(max_length=32)
    address_info = models.CharField(max_length=32)
    express_fee = models.CharField(max_length=32)
    order_status = models.CharField(max_length=32)
    qrcode = models.CharField(max_length=100)
    company = models.CharField(max_length=50, default='')
    ctime = models.DateTimeField('创建时间', null=True, auto_now_add=True)
    utime = models.DateTimeField('更新时间', null=True, auto_now_add=True)

    # 'address_info': '[object Object]',
    #  'payway': 'wx',
    #  'all_fee': None,
    #  'discount': '0',
    #  'pre_order_id': 'undefined'

    class Meta:
        db_table = 'zz_Order'
